package org.raymond.iworks.study.basic.designpattern.iterator;

import java.util.Iterator;

/**
 * @author raymond
 * @version V1.0
 * @Description: TODO
 */
public class ComputerCollege implements College{
    private Department[] departments;
    private int idx;

    public ComputerCollege() {
        departments = new Department[5];
        addDepartment("java", "java");
        addDepartment("大数据", "大数据");
        addDepartment("netty", "netty");
    }

    @Override
    public Iterator createIterator() {
        return new ComputerCollegeIterator(departments);
    }

    @Override
    public String name() {
        return "计算机学院";
    }

    @Override
    public void addDepartment(String name, String desc) {
        Department department = new Department(name, desc);
        departments[idx] = department;
        idx++;
    }
}
